from sklearn.datasets import load_iris, fetch_20newsgroups
import seaborn as sns
import matplotlib.pyplot as plt
import pandas as pd
import matplotlib.pyplot as plt
from sklearn.model_selection import train_test_split

plt.rcParams['font.sans-serif'] = ['SimHei']  # 使用黑体显示中文
plt.rcParams['axes.unicode_minus'] = False  # 解决负号显示问题

iris = load_iris()

# print(iris)
# 数据下载在C:\Users\wlw\scikit_learn_data
# news = fetch_20newsgroups()
# print(news)
iris_d = pd.DataFrame(data=iris.data, columns=['Sepal_Length', 'Sepal_Width', 'Petal_Length', 'Petal_Width'])
iris_d["target"] = iris.target


def iris_plot(data, col1, col2):
    sns.lmplot(x=col1, y=col2, data=data, hue="target")
    plt.title("鸢尾花数据显示")
    plt.show()


# iris_plot(iris_d, 'Sepal_Width','Petal_Length')
x_train, x_test, y_train, y_test = train_test_split(iris.data, iris.target, test_size=0.2, random_state=22)
print("训练集的特征值是:\n", x_train)
print("训练集的目标值是:\n", y_test)
print("测试集的特征值是:\n", x_train)
print("测试集的目标值是:\n", y_test)

print("训练集的目标值形状是:\n", y_train.shape)
print("测试集的目标值形状是:\n", y_test.shape)